Near field communication (NFC) is a short-range wireless connection technology that is based on radio frequency identification (RFID), to implement close-range communication between electronic devices by using magnetic field induction. An effective communication range of the NFC is 0 cm to 20 cm. The NFC may be applied to near field payment. Provided that a user gets a device in contact with another device or gets a device close to another device, information exchange and transaction payment can be safely and quickly performed.
Operating modes of an NFC device may be mainly classified into the following three modes:
1. a peer-to-peer (P2P) mode, used in a scenario such as contact card sharing, web page sharing, or NFC pairing;
2. a card emulation (CE) mode, used in a mobile payment scenario or an identity authentication scenario such as bank card emulation, transportation card emulation, membership card emulation, coupon emulation, or identification card emulation; and
3. a reader/writer (R/W) mode, used in a mobile payment scenario or an identity authentication scenario, and a label reader/writer scenario, such as bank card POS machine emulation or bus POS machine emulation.
As shown in FIG. 1, an NFC device mainly includes the following three functional entities: a main controller (Device Host, DH), an NFC controller (NFCC), and an NFC execution environment (NFCEE). The DH is responsible for management of the entire NFC device, including management of the NFCC, for example, initialization, parameter configuration, or power supply management. The NFCC is an entity of an NFC chip responsible for data transmission. Usually, the NFCC is directly used to indicate the NFC chip. The NFCEE provides a secure execution environment for an NFC application (App). A mobile phone is used as an example. The DH may be corresponding to a central processing unit (CPU) of the mobile phone. The NFCC may be corresponding to an NFC chip. The NFCEE may be corresponding to multiple physical forms such as a universal integrated circuit card UICC), an embedded secure element (eSE), and a secure digital memory card (SD card), or may be corresponding to a soft environment such as host card emulation (HCE). FIG. 1 further includes a DH-NFCEE. The DH-NFCEE is an NFCEE that is connected to only the DH or that is integrated into the DH. A logical interface for communication between the DH and the NFCC is defined in the NFC controller interface (NCI) specification formulated by the NFC Forum. In addition, the NFCC may communicate with the NFCEE or the DH may communicate with the NFCEE by using the Host Controller Interface (HCI) Communications Protocol.
According to the NCI specification, an NFC device discovers another NFC device by using a radio frequency (RF) discovery process. Usually, in the RF discovery process, an NFC device on one end is in a poll mode (English name: Poll Mode), and a peer NFC device is in a listen mode (English name: Listen Mode). Usually, the NFC device sends a command and receives a response, in a poll mode; and receives a command and sends a response, in a listen mode.
Four types of RF technologies NFC-A, NFC-B, NFC-F, and NFC-V are defined in a current NCI specification. In all the four types of RF technologies, a 13.56 MHz RF carrier is used, and a same RF protocol may be supported, but different modulation schemes, bit codes, and frame formats are used. The RF protocol is a protocol used when NFC devices communicate with each other. One RF technology may support multiple RF protocols, and one RF protocol may be corresponding to multiple RF technologies. Multiple applications may be installed on an NFCEE of the NFC device. Each application supports one or more RF technologies, but one application generally supports only one RF protocol. A correspondence between the RF technology and the RF protocol is shown in FIG. 2. NFC-A is used as an example. It can be learned from FIG. 2 that an NFC-A technology may support four RF protocols T1T, T2T, ISO-DEP (T4AT/T4BT), and NFC-DEP.
In a radio frequency discovery process, an NFC device in a poll mode (hereinafter referred to as a poll device) successively sends detection commands for the four RF technologies, to detect RF technologies supported by a peer device; then further detects, according to the RF technologies supported by the peer device, specific RF protocols supported by the peer device; and finally, selects one protocol from the detected RF protocols supported by the peer device, to perform communication between the poll device and the peer device.
However, according to an existing radio frequency discovery process, an application corresponding to an RF protocol selected by a poll device usually does not meet user's intention. When the application corresponding to the RF protocol selected by the poll device does not meet the user's intention, the poll device may initiate the radio frequency discovery process again to reselect an RF protocol. Consequently, radio frequency discovery efficiency is low, and resources are wasted.